//
//  SecondTabView.swift
//  SwiftUI_App
//
//  Created by qingzhou on 2021/6/3.
//

import SwiftUI

struct SecondTabView: View {

    @EnvironmentObject var stateManager: StateManager
    @State private var isPresentingOverlay: Bool = false
    
    var body: some View {
        NavigationView {
            VStack {
                Text("我的页面")
                Button(action:{
                    isPresentingOverlay.toggle()
                }){
                    Text("展示视图模态")
                }
                    .fullScreenCover(isPresented: $isPresentingOverlay, content: {
                        VStack {
                            Text("我是另一个视图")
                            Button(action:{
                                isPresentingOverlay = false
                            }){
                               Text("关闭")
                            }
                        }
                        .frame(maxWidth: .infinity, maxHeight: .infinity)
                        .background(Color.yellow)
                })
                
                Button(action:{
                    stateManager.selection = 1
                    stateManager.firstDetailsShow = true
                }){
                    Text("去第一个页面的详情页")
                }
            }
        }
        .navigationTitle("我的")
    }
}

struct secondTabView_Previews: PreviewProvider {
    static var previews: some View {
        SecondTabView()
    }
}
